<!DOCTYPE html>
<html>
<head>
<title>Febit Wit (Webit Script)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="Shortcut Icon" href="favicon.ico" />
<link rel="stylesheet" href="css/css.css" media="screen"/>
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top">
<div class="ws-container">
<div class="navbar-header">
<a href="index.html" class="navbar-brand">Febit Wit</a>
</div>
<div id="navbar-main" class="navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">简介</a></li>
<li><a href="example.html">示例</a></li>
<li><a href="syntax.html">语法</a></li>
<li><a href="props.html">配置</a></li>
<li><a href="integration.html">集成</a></li>
<li><a href="libapi.html">库/API</a></li>
<li><a href="faq.html">常见问题</a></li>
<li><a href="https://github.com/zqq90/zqq90.github.io/archive/master.zip" style="color: #fae413" target="_blank">下载本文档</a></li>
</div>
</div>
</div>
<div class="ws-container ws-doc-main-body"><div class="ws-sidenav"><ul class="nav"><li><a href="#hello-wit">Hello Wit</a></li><li><a href="#section">调用示例</a></li><li><a href="#mvc">MVC视图集成</a></li></ul></div><div class="ws-doc-body" ><h2 id="hello-wit">Hello Wit</h2>

<pre class="brush: javascript;">Hello Febit Wit!
&lt;%
    var books;
    //遍历集合
    for(book : books){
%&gt;
${for.iter.index}.《${book.name}》 ￥${book.price}
&lt;%
    }
%&gt;

&lt;%
    //自定义函数
    var func = function(a, b){
        return a + b + arguments[3];
    };
    echo func("a", "b", "c");
    echo '\n';
%&gt;
&lt;%
    //声明Map
    var map = {
        1: 1,
        "key2": "value2",
        3: 2 + 1
    };
    //map 读写
    map[5] = 2 + 3;
    // 调用成员函数
    map.~put("6",2*3);
    //map 遍历
    for(key, value : map){
        //输出
        echo key + ":" +value + "\n";
    }
%&gt;
</pre>

<p>更多实例可见:<a href="https://github.com/febit/wit/tree/master/wit-core/src/test/resources/org/febit/wit/test/tmpls">测试模板</a></p>

<h2 id="section">调用示例</h2>
<pre class="brush: java;">// engine 并不会被缓存, 请根据需要缓存 Engine 实例
Engine engine = Engine.create("/wit-engine.wim", extraSettingsMap);

// template 会缓存在 engine 中, 线程安全
Template template = engine.getTemplate("/path/to/demo.wit");

//输出out可以是 OutputStream 或者 Writer
template.merge(paramsMap, out); 
</pre>

<h2 id="mvc">MVC视图集成</h2>

<ul>
  <li>Jodd Madvoc</li>
  <li>JFinal</li>
  <li>Spring MVC</li>
  <li>Struts</li>
  <li>Servlet &amp; Filter</li>
</ul>

<p><a href="https://github.com/zqq90/webitscript-mvc-demo">示例代码</a></p>

</div>
<div class="footer">
版权所有 2013-2017 febit.org
</div>
</div>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript">SyntaxHighlighter.all();</script>
</body>
</html>
